import uvicorn
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from public.utils import local_ip

app = FastAPI()  # 仅局域网可访问
api = FastAPI()  # 透传到外部网络
app.mount('/api', api)

# 允许所有来源、所有方法、所有头
app.add_middleware(
    CORSMiddleware,  # type: ignore
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

uv_server = uvicorn.Server(uvicorn.Config(
    "masterServer.comm.app:app",
    host=local_ip(),
    port=9000,
))
